import sys
import os
from plHandler import playlistHandler
from Cookie import SimpleCookie
from Output import output

if sys.platform == "win32":
    import msvcrt
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)


pl = playlistHandler(output.LOGMODE)

method = "GET"
fileName = "./index.m3u8"
# output = []

fileName = "./01.m3u8"
#fileName = "20110203T230818-01-118403.ts"
#files = ["index.m3u8", "01.m3u8", "02.m3u8", "03.m3u8"]

cookie = SimpleCookie()
cookie["user"] = "shafiq"

#os.environ["HTTP_COOKIE"] = str(cookie)

#for fileName in files:
output = pl.HandleRequest(method, fileName)
print "\noutput: ", output